<?php
/**
 * 微信JSSDK权限配置可用参数列表
 *
 * Author: Zeon
 * Date: 2016/12/2
 * Created by Panxsoft.
 */
namespace App\Services\OpenWechat;

class JSSDKConfig
{
    /**
     * @link https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115 微信JSSDK参考文档
     * @var string
     */
    public static $all_configs = <<<CONFIG_TEMPLATE
onMenuShareTimeline
onMenuShareAppMessage
onMenuShareQQ
onMenuShareWeibo
onMenuShareQZone
startRecord
stopRecord
onVoiceRecordEnd
playVoice
pauseVoice
stopVoice
onVoicePlayEnd
uploadVoice
downloadVoice
chooseImage
previewImage
uploadImage
downloadImage
translateVoice
getNetworkType
openLocation
getLocation
hideOptionMenu
showOptionMenu
hideMenuItems
showMenuItems
hideAllNonBaseMenuItem
showAllNonBaseMenuItem
closeWindow
scanQRCode
chooseWXPay
openProductSpecificView
addCard
chooseCard
openCard
openEnterpriseRedPacket
startSearchBeacons
stopSearchBeacons
onSearchBeacons
consumeAndShareCard
openAddress
CONFIG_TEMPLATE;
    // index = line number - 14

    /**
     * 返回指定或全部
     * @param null|int|array $index_arr
     * @return array
     */
    public static function get( $index_arr = null )
    {
        $config_arr = explode( "\n" , self::$all_configs );
        if ( ! $index_arr || (is_array($index_arr) && ! count($index_arr)) )
        {
            return $config_arr;
        }
        else
        {
            return array_map(function( $index ) use ($config_arr) {
                return $config_arr[$index];
            }, $index_arr);
        }
    }

}